#pragma once

#include<glut.h>
#include<list>

#include"RichChar.h"
#include"Cursor.h"
#include"CharcterDisplayer.h"
#include"Vector2D.h"

class TextInstance
{
public:
	TextInstance()
	{
		_cursor.It = _chars.end();
	}
	void display()
	{
		std::list<RichChar>::iterator itNow;
		Vector2D positionNow;
		positionNow.Y = -12;
		glColor3f(0.0 , 0.0 , 0.0);
		for(itNow = _chars.begin() ; itNow != _chars.end() ; ++itNow)
		{
			std::cout << (char)(*itNow).Data << " ";
			glRasterPos2f(positionNow.X , positionNow.Y);
			_charcterDisplayer.Print((*itNow).Data , (*itNow).Size);
			positionNow.X += (*itNow).Size;
		}
		std::cout << std::endl;
	}
	void ToggleCursor()
	{
	}
	void CharEvent(const wchar_t& newChar)
	{
		RichChar newRichChar(newChar);
		_chars.insert(_cursor.It , newRichChar);
	}
private:
	std::list<RichChar> _chars;
	Cursor _cursor;
	CharcterDisplayer _charcterDisplayer;
};
